package com.ihtry.dao;

import com.ihtry.pojo.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface BookDao {
    /**
     * 添加图书
     */
    @Insert("insert into book(name,author,price,number) values(#{name},#{author},#{price},#{number})")
    public boolean addBook(Book book);

    /**
     * 删除图书
     */
    @Delete("delete from book where id = #{id}")
    public boolean deleteBook(Integer id);

    /**
     * 修改图书
     */
    
    @Update("update book set name = #{name} ,author = #{author} ,price = #{price} ,number = #{number} where id = #{id}")
    public boolean updateBook(Book book);

    /**
     * 查询全部
     */
    @Select("select * from book order by id desc")
    public List<Book> getAll();

    /**
     * 通过id查询
     */
    @Select("select * from book where id = #{id}")
    public Book getBookById(Integer id);
}
